package com.cynteka.cyfoman.core.collection;

import java.io.File;

/**
 * User: Sergey
 * Date: 29.07.11
 * Time: 13:00
 */
public class FileRegistryAppender implements IRegistryAppender {

    private File baseFolder;
    private String collectionId;
    private String linkId;
    private boolean filterHiddenFiles;

    public boolean isFilterHiddenFiles() {
        return filterHiddenFiles;
    }

    public void setFilterHiddenFiles(boolean filterHiddenFiles) {
        this.filterHiddenFiles = filterHiddenFiles;
    }

    public FileRegistryAppender() {
    }

    public FileRegistryAppender(File baseFolder, String collectionId, String linkId) {
        this.baseFolder = baseFolder;
        this.collectionId = collectionId;
        this.linkId = linkId;
    }

    public File getBaseFolder() {
        return baseFolder;
    }

    public void setBaseFolder(File baseFolder) {
        this.baseFolder = baseFolder;
    }

    public String getCollectionId() {
        return collectionId;
    }

    public void setCollectionId(String collectionId) {
        this.collectionId = collectionId;
    }

    public String getLinkId() {
        return linkId;
    }

    public void setLinkId(String linkId) {
        this.linkId = linkId;
    }

    @Override
    public ICollection<?>[] getCollections() {
        FileCollection collection = new FileCollection(collectionId, baseFolder);
        collection.setFilterHiddenFiles(filterHiddenFiles);
        return new ICollection<?>[]{collection};
    }

    @Override
    public ILink[] getLinks() {
        FileLink fileLink = new FileLink(linkId, collectionId);
        fileLink.setFilterHiddenFiles(filterHiddenFiles);
        return new ILink[]{fileLink};
    }
}
